package com.yanqu.road.server.cmd.activity.shushan;


import com.yanqu.road.pb.activity.ShuShanProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.shushan.ShuShanMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Description
 * @Author cwq
 * @Data 2022/1/20 15:28
 */
@Cmd(code = GameProtocol.S_SHUSHAN_GET_LILIAN_GRID_INFO, desc = "蜀山 获取格子信息")
public class ShuShanGetShuShanGridInfoCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ShuShanProto.ShuShanGetLiLianGridInfoReqMsg reqMsg = ShuShanProto.ShuShanGetLiLianGridInfoReqMsg.parseFrom(packet.getBytes());
        ret = ShuShanMgr.canEntryActivity(player, reqMsg.getActivityId());
        if(ret != 0){
            return;
        }

        player.sendPacket(ClientProtocol.U_SHUSHAN_GET_LILIAN_GRID_INFO, ShuShanMgr.getLiLianGrad(player, reqMsg.getId()));
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            ShuShanProto.ShuShanGetLiLianGridInfoRespMsg.Builder builder = ShuShanProto.ShuShanGetLiLianGridInfoRespMsg.newBuilder();
            builder.setRet(ret);
            player.sendPacket(ClientProtocol.U_SHUSHAN_GET_LILIAN_GRID_INFO, builder);
        }
    }
}
